package com.ynunicom.dc.dingdingcontractapp.utils;

import org.flowable.task.api.Task;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author: jinye.Bai
 * @date: 2020/6/4 9:29
 */

/**
 * TaskList取交集工具
 */
public class TaskCrossList {

    public static List<Task> taskCrossList(List<Task> taskListA,List<Task> taskListB){
        List<Task> returnList = new ArrayList<>();
        if (taskListA.isEmpty()||taskListB.isEmpty()){
            return returnList;
        }
        for (Task taskA :
                taskListA) {
            for (Task taskB:
                 taskListB) {
                if (taskA.getId().equals(taskB.getId())){
                    returnList.add(taskB);
                }
            }
        }
        Set<Task> set = new HashSet<>(returnList);
        return new ArrayList<>(set);
    }

}
